package com.yswy.app.scheduled;

import com.yswy.app.service.AgreementOrderService;
import com.yswy.app.service.PayOrderService;
import com.yswy.app.service.TgCallBackIdService;
import com.yswy.app.service.TransferOrderService;
import com.yswy.app.service.impl.AgreementOrderPayLogServiceImpl;
import com.yswy.common.utils.DateUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.Date;


@Async  //开启异步线程执行任务
@Slf4j
@Component
@EnableScheduling //标注启动定时任务
public class ScheduledService {
    @Autowired
    private AgreementOrderPayLogServiceImpl agreementOrderPayLogService ;
    @Autowired
    private PayOrderService payOrderService ;
    @Autowired
    private TgCallBackIdService tgCallBackIdService ;
    @Autowired
    private TransferOrderService transferOrderService ;

    @Autowired
    private AgreementOrderService agreementOrderService ;


    @Scheduled(cron = "0 */5 * * * ?")
    public void userAgreementPayOrder(){
        log.info("=====>>>>>周期付款订单收款token:cron  {}", DateUtils.getNowDate(new Date()));
        agreementOrderPayLogService.userAgreementPayOrderV2();
    }

    @Scheduled(cron = "0 */5 * * * ?")
    public void delPayOrder(){
        log.info("=====>>>>>轮询取消待付款超时订单token:cron  {}", DateUtils.getNowDate(new Date()));
        payOrderService.delPayOrder();
    }
    @Scheduled(cron = "0 */2 * * * ?")
    public void wxTransferOrderStatus(){
        log.info("=====>>>>>轮询取查询微信转账状态token:cron  {}", DateUtils.getNowDate(new Date()));
        transferOrderService.wxTransferOrderStatus();
    }

//    @Scheduled(cron = "0 */1 * * * ?")
//    public void callBackAgreementOrder(){
//        log.info("=====>>>>>延时执行签约回传:cron  {}", DateUtils.getNowDate(new Date()));
//        agreementOrderService.callBackAgreementOrder();
//    }

}
